{include file="public/header" /}
<body class="gray-bg">
<div class="wrapper wrapper-content">
    <div class="ibox-title">
        <h5>闯关试题</h5>
    </div>
    <div class="ibox-content layui-form">
        <div class="layui-row layui-col-space10 layui-form-item ">
            <input type="hidden" name="id" value="{$info['rb_id']}">
            <div class="layui-form-item layui-col-md-offset1 layui-col-md8">
                <label class="layui-form-label">书名：</label>
                <div class="layui-input-block">
                    <input type="text" name="rb_name" value="{$info['rb_name']}" lay-verify="required" class="layui-input ">
                </div>
            </div>
            <div class="layui-form-item layui-col-md-offset1 layui-col-md8">
                <label class="layui-form-label">缩略图：</label>
                <input type="hidden" name="img" id="lay-img" lay-verify="image" value="{$info.rb_image}">
                <div class="layui-input-block">
                    <div id="lay-upload">上传图片</div>
                    <blockquote class="layui-elem-quote layui-quote-nm" style="margin-top: 10px;">
                        预览图：
                        <div class="layui-upload-list" id="lay-list">
                            <img class="layui-append-img" src="{$info.rb_image}" onerror="this.src='/static/admin/images/no_img.jpg'">
                        </div>
                    </blockquote>
                </div>
            </div>
            <div class="layui-form-item layui-col-md-offset1 layui-col-md8">
                <label class="layui-form-label">作者：</label>
                <div class="layui-input-block">
                    <input type="text" name="rb_author" value="{$info['rb_author']}" lay-verify="required" class="layui-input ">
                </div>
            </div>
            <div class="layui-form-item layui-col-md-offset1 layui-col-md8">
                <label class="layui-form-label">出版社：</label>
                <div class="layui-input-block">
                    <input type="text" name="rb_company" value="{$info['rb_company']}" lay-verify="required" class="layui-input ">
                </div>
            </div>
            <div class="layui-form-item layui-col-md-offset1 layui-col-md8">
                <label class="layui-form-label">版本：</label>
                <div class="layui-input-block">
                    <input type="text" name="rb_version" value="{$info['rb_version']}" lay-verify="required" class="layui-input ">
                </div>
            </div>
            <div class="layui-form-item layui-col-md-offset1 layui-col-md8">
                <label class="layui-form-label">评分：</label>
                <div class="layui-input-block">
                    <input type="text" name="rb_score" value="{$info['rb_score']}" lay-verify="required" class="layui-input ">
                </div>
            </div>
            <div class="layui-form-item layui-col-md-offset1 layui-col-md8">
                <label class="layui-form-label">适用年级：</label>
                <div class="layui-input-block">
                    <select name="rb_grade_id">
                        {foreach name="info1" item="vv"}
                        <option value="{$vv.grade_id}" {if $vv['grade_id']==$info['rb_grade_id']}selected{/if}>{$vv.grade_name}</option>
                        {/foreach}
                    </select>
                </div>
            </div>
            <div class="layui-form-item layui-col-md-offset1 layui-col-md8">
                <label class="layui-form-label">类型：</label>
                <div class="layui-input-block">
                    <select name="rb_book_type_name">
                        {foreach name="book_type" item="vv"}
                        <option value="{$vv.book_type_name}" {if $vv['book_type_name']==$info['rb_book_type_name']}selected{/if}>{$vv.book_type_name}</option>
                        {/foreach}
                    </select>
                </div>
            </div>
            <div class="layui-form-item layui-col-md-offset1 layui-col-md8">
                <div class="layui-input-block">
                    <button class="layui-btn" lay-submit="" lay-filter="component-form-element">保存
                    </button>
                </div>
            </div>
        </div>
    </div>
</div>
{include file="public/footer" /}
<script>
    wk.uploadImg({size:5,type:'png,jpg,jpeg',url:"{:url('Upload/upload')}",domain:""});
    layui.use(['form'], function() {
        var form = layui.form;
        form.on('submit(component-form-element)', function (data) {
            $('.layui-btn').addClass('layui-disabled').attr('disabled','disabled');
            $.ajax({
                url:"{:url('update')}",
                type:'post',
                dataType:'json',
                data:data.field,
                success:function(res){
                    if (res.code == 200) {
                        wk.success(res.msg,"{:url('book/index')}")
                    } else {
                        wk.error(res.msg,'','$(".layui-btn").removeClass(\'layui-disabled\').removeAttr(\'disabled\');');
                    }
                }
            })
        });
    });
</script>
</body>
</html>